﻿using MTBrainStorm.Models.VirtualKeyboard.VirtualKeyCodes;
using MTBrainStorm.ViewModels;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MTBrainStorm.Tests
{
    
    
    /// <summary>
    ///This is a test class for VirtualKeyboardViewModelTest and is intended
    ///to contain all VirtualKeyboardViewModelTest Unit Tests
    ///</summary>
    [TestClass()]
    public class VirtualKeyboardViewModelTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for VirtualKeyboardViewModel Constructor
        ///</summary>
        [TestMethod()]
        public void VirtualKeyboardViewModelConstructorTest()
        {
            var target = new VirtualKeyboardViewModel();
            var expected = string.Empty;
            var actual = target.Text;
            Assert.AreEqual(expected, actual, "Text property should be empty");
        }

        [TestMethod]
        public void VirtualKeyboardViewModelConstructorTest2()
        {
            var target = new VirtualKeyboardViewModel { Text = "Test value" };
            var expected = "Test value";
            var actual = target.Text;
            Assert.AreEqual(expected, actual, "Text property should not be empty");
        }

        /// <summary>
        ///A test for Text
        ///</summary>
        [TestMethod()]
        public void TextTest()
        {
            var target = new VirtualKeyboardViewModel();
            string expected = "Test value";
            string actual;
            target.Text = expected;
            actual = target.Text;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void PressKeyCommandTest()
        {
            var target = new VirtualKeyboardViewModel();
            
            target.PressKeyCommand.Execute(Characters.Slash);
            Assert.AreEqual("/", target.Text, "Command execution failed");

            target.PressKeyCommand.Execute(Characters.T);
            Assert.AreEqual("/t", target.Text, "Command execution failed");
        }

        [TestMethod]
        public void BackspaceCommandTest()
        {
            var target = new VirtualKeyboardViewModel();

            target.Text = "Test string";
            Assert.AreNotEqual(string.Empty, target.Text, "Text property should not be empty");

            target.PressSpecialKeyCommand.Execute(Specials.Backspace);
            Assert.AreEqual("Test strin", target.Text, "Command execution failed");
        }

        [TestMethod]
        public void BackspaceCommandWithEmptyTextTest()
        {
            var target = new VirtualKeyboardViewModel();
            target.PressSpecialKeyCommand.Execute(Specials.Backspace);
        }
    }
}
